﻿using System;

namespace _108_解构自定义类型_无组
{
    class Program
    {
        static void Main(string[] args)
        {
            Order open = new Order
            {
                OID = 6012001,
                CustomName = "江西逐浪软件科技有限公司",
                ContactName = "汪先生",
                Amout = 1700.34f,
                PhoneNo = "13177777714"
            };

            //对order实例进行解构
            var (id, cust, contact, amout, phone) = open;
            Console.WriteLine($"订单号：{id}\n客户单位：{cust}\n联系人：{contact}\n订购数量：{amout}\n电话：{phone}");
            Console.Read();

        }
    }

    public class Order
    {
        public int OID { get; set; }
        public string CustomName { get; set; }
        public string ContactName { get; set; }
        public float Amout { get; set; }
        public string PhoneNo { get; set; }

        //解析方法
        public void Deconstruct(out int oid, out string custName, out string contact, out float amount, out string phone)
        {
            oid = OID;
            custName = CustomName;
            contact = ContactName;
            amount = Amout;
            phone = PhoneNo;
        }
    }

}
